package com.aspose.cells.b.a.a;

import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;

public class zd<K, V> implements Iterable<za<K, V>> {
   private K[] b;
   private V[] c;
   private int d;
   private Comparator<? super K> e;
   private zd<K, V>.za f;
   private zd<K, V>.zc g;
   private final int h;

   public zd() {
      this.e = null;
      this.h = 16;
      this.b = (Object[])(new Object[16]);
      this.c = (Object[])(new Object[16]);
   }

   public zd(Comparator var1) {
      this();
      if (var1 != null) {
         this.e = var1;
      }

   }

   public void a(K var1, V var2) {
      int var3 = a(this.b, 0, this.d, var1, this.e);
      if (var3 >= 0) {
         throw new IllegalArgumentException("duplicate");
      } else {
         this.a(~var3, var1, var2);
      }
   }

   public void a(int var1) {
      if (var1 != this.b.length) {
         if (var1 < this.d) {
            throw new IndexOutOfBoundsException("value");
         }

         if (var1 > 0) {
            Object[] var2 = (Object[])(new Object[var1]);
            Object[] var3 = (Object[])(new Object[var1]);
            if (this.d > 0) {
               System.arraycopy(this.b, 0, var2, 0, this.d);
               System.arraycopy(this.c, 0, var3, 0, this.d);
            }

            this.b = var2;
            this.c = var3;
         } else {
            this.b = (Object[])(new Object[16]);
            this.c = (Object[])(new Object[16]);
         }
      }

   }

   public int b() {
      return this.d;
   }

   public boolean a(K var1) {
      return this.e(var1) >= 0;
   }

   public boolean b(K var1) {
      return this.e(var1) >= 0;
   }

   public boolean c(V var1) {
      return this.f(var1) >= 0;
   }

   private void e(int var1) {
      int var2 = this.b.length == 0 ? 16 : this.b.length << 1;
      if (var2 < var1) {
         var2 = var1;
      }

      this.a(var2);
   }

   public V b(int var1) {
      if (var1 >= 0 && var1 < this.d) {
         return this.c[var1];
      } else {
         throw new IndexOutOfBoundsException("index");
      }
   }

   public Iterator<za<K, V>> iterator() {
      return new zd.zb();
   }

   public K c(int var1) {
      if (var1 >= 0 && var1 < this.d) {
         return this.b[var1];
      } else {
         throw new IndexOutOfBoundsException("index");
      }
   }

   public Iterable<K> c() {
      return this.d();
   }

   public List<K> d() {
      if (this.f == null) {
         this.f = new zd.za(this);
      }

      return this.f;
   }

   public List<V> e() {
      if (this.g == null) {
         this.g = new zd.zc(this);
      }

      return this.g;
   }

   public Iterable<V> f() {
      return this.e();
   }

   public V d(K var1) {
      int var2 = this.e(var1);
      return var2 >= 0 && var2 < this.d ? this.c[var2] : null;
   }

   public void b(K var1, V var2) {
      if (var1 == null) {
         throw new NullPointerException("key");
      } else {
         int var3 = a(this.b, 0, this.d, var1, this.e);
         if (var3 >= 0) {
            this.c[var3] = var2;
         } else {
            this.a(~var3, var1, var2);
         }
      }
   }

   public int e(K var1) {
      if (var1 == null) {
         throw new NullPointerException("key");
      } else {
         int var2 = a(this.b, 0, this.d, var1, this.e);
         return var2 >= 0 ? var2 : -1;
      }
   }

   public int f(V var1) {
      return com.aspose.cells.b.a.za.a(this.c, var1, 0, this.d);
   }

   private void a(int var1, K var2, V var3) {
      if (this.d == this.b.length) {
         this.e(this.d + 1);
      }

      if (var1 < this.d) {
         System.arraycopy(this.b, var1, this.b, var1 + 1, this.d - var1);
         System.arraycopy(this.c, var1, this.c, var1 + 1, this.d - var1);
      }

      this.b[var1] = var2;
      this.c[var1] = var3;
      ++this.d;
   }

   public void d(int var1) {
      if (var1 >= 0 && var1 < this.d) {
         --this.d;
         if (var1 < this.d) {
            System.arraycopy(this.b, var1 + 1, this.b, var1, this.d - var1);
            System.arraycopy(this.c, var1 + 1, this.c, var1, this.d - var1);
         }

         this.b[this.d] = null;
         this.c[this.d] = null;
      } else {
         throw new IndexOutOfBoundsException("index");
      }
   }

   public void g(K var1) {
      int var2 = this.e(var1);
      if (var2 >= 0) {
         this.d(var2);
      }

   }

   public static int a(Object[] var0, int var1, int var2, Object var3) {
      assert var0 != null;

      assert var1 >= 0 && var2 >= 0;

      assert var0.length - var1 >= var2;

      int var4 = var1;
      int var5 = var1 + var2 - 1;

      while(var4 <= var5) {
         int var6 = var4 + var5 >> 1;
         Comparable var7 = (Comparable)var0[var6];
         int var8 = var7.compareTo(var3);
         if (var8 < 0) {
            var4 = var6 + 1;
         } else {
            if (var8 <= 0) {
               return var6;
            }

            var5 = var6 - 1;
         }
      }

      return ~var4;
   }

   public static <T> int a(T[] var0, int var1, int var2, T var3, Comparator<? super T> var4) {
      assert var0 != null;

      assert var1 >= 0 && var2 >= 0;

      assert var0.length - var1 >= var2;

      if (var4 == null) {
         return a(var0, var1, var2, var3);
      } else {
         int var5 = var1;
         int var6 = var1 + var2 - 1;

         while(var5 <= var6) {
            int var7 = var5 + var6 >> 1;
            Object var8 = var0[var7];
            int var9 = var4.compare(var8, var3);
            if (var9 < 0) {
               var5 = var7 + 1;
            } else {
               if (var9 <= 0) {
                  return var7;
               }

               var6 = var7 - 1;
            }
         }

         return ~var5;
      }
   }

   public String toString() {
      StringBuilder var1 = new StringBuilder("\r\n");
      Iterator var2 = this.iterator();

      while(var2.hasNext()) {
         za var3 = (za)var2.next();
         var1.append(var3.getKey()).append(" => ").append(var3.getValue()).append("\r\n");
      }

      return var1.toString();
   }

   private class zc implements List<V> {
      private zd<K, V> b;

      zc(zd<K, V> var2) {
         this.b = var2;
      }

      public boolean add(V o) {
         throw new UnsupportedOperationException();
      }

      public void add(int index, V element) {
         throw new UnsupportedOperationException();
      }

      public boolean addAll(Collection<? extends V> c) {
         throw new UnsupportedOperationException();
      }

      public boolean addAll(int index, Collection<? extends V> c) {
         throw new UnsupportedOperationException();
      }

      public void clear() {
         throw new UnsupportedOperationException();
      }

      public boolean contains(Object value) {
         return this.b.c(value);
      }

      public boolean containsAll(Collection<?> c) {
         throw new UnsupportedOperationException();
      }

      public V get(int index) {
         return this.b.b(index);
      }

      public int indexOf(Object value) {
         return com.aspose.cells.b.a.za.a(this.b.c, value, 0, this.b.b());
      }

      public boolean isEmpty() {
         return this.b.b() == 0;
      }

      public Iterator<V> iterator() {
         return new zd.zc.za();
      }

      public int lastIndexOf(Object o) {
         throw new UnsupportedOperationException();
      }

      public ListIterator<V> listIterator() {
         throw new UnsupportedOperationException();
      }

      public ListIterator<V> listIterator(int index) {
         throw new UnsupportedOperationException();
      }

      public V remove(int index) {
         throw new UnsupportedOperationException();
      }

      public boolean remove(Object o) {
         throw new UnsupportedOperationException();
      }

      public boolean removeAll(Collection<?> c) {
         throw new UnsupportedOperationException();
      }

      public boolean retainAll(Collection<?> c) {
         throw new UnsupportedOperationException();
      }

      public V set(int index, V element) {
         throw new UnsupportedOperationException();
      }

      public int size() {
         return this.b.d;
      }

      public List<V> subList(int fromIndex, int toIndex) {
         throw new UnsupportedOperationException();
      }

      public Object[] toArray() {
         throw new UnsupportedOperationException();
      }

      public <V> V[] toArray(V[] a) {
         throw new UnsupportedOperationException();
      }

      private class za implements Iterator<V> {
         private int b;

         private za() {
            this.b = -1;
         }

         public boolean hasNext() {
            return this.b + 1 < zd.this.b();
         }

         public V next() {
            if (++this.b >= zd.this.b()) {
               throw new NoSuchElementException("Iteration has no more elements.");
            } else {
               return zc.this.b.b(this.b);
            }
         }

         public void remove() {
            throw new UnsupportedOperationException();
         }

         // $FF: synthetic method
         za(Object var2) {
            this();
         }
      }
   }

   private class za implements List<K> {
      private zd<K, V> b;

      za(zd<K, V> var2) {
         this.b = var2;
      }

      public boolean add(K o) {
         throw new UnsupportedOperationException();
      }

      public void add(int index, K element) {
         throw new UnsupportedOperationException();
      }

      public boolean addAll(Collection<? extends K> c) {
         throw new UnsupportedOperationException();
      }

      public boolean addAll(int index, Collection<? extends K> c) {
         throw new UnsupportedOperationException();
      }

      public void clear() {
         throw new UnsupportedOperationException();
      }

      public boolean contains(Object value) {
         return this.b.b(value);
      }

      public boolean containsAll(Collection<?> c) {
         throw new UnsupportedOperationException();
      }

      public K get(int index) {
         return this.b.c(index);
      }

      public int indexOf(Object key) {
         if (key == null) {
            throw new NullPointerException("key");
         } else {
            int var2 = zd.a(this.b.b, 0, this.b.b(), key, this.b.e);
            return var2 >= 0 ? var2 : -1;
         }
      }

      public boolean isEmpty() {
         return this.b.b() == 0;
      }

      public Iterator<K> iterator() {
         return new zd.za.za();
      }

      public int lastIndexOf(Object o) {
         throw new UnsupportedOperationException();
      }

      public ListIterator<K> listIterator() {
         throw new UnsupportedOperationException();
      }

      public ListIterator<K> listIterator(int index) {
         throw new UnsupportedOperationException();
      }

      public K remove(int index) {
         throw new UnsupportedOperationException();
      }

      public boolean remove(Object o) {
         throw new UnsupportedOperationException();
      }

      public boolean removeAll(Collection<?> c) {
         throw new UnsupportedOperationException();
      }

      public boolean retainAll(Collection<?> c) {
         throw new UnsupportedOperationException();
      }

      public K set(int index, K element) {
         throw new UnsupportedOperationException();
      }

      public int size() {
         return this.b.d;
      }

      public List<K> subList(int fromIndex, int toIndex) {
         throw new UnsupportedOperationException();
      }

      public Object[] toArray() {
         throw new UnsupportedOperationException();
      }

      public <K> K[] toArray(K[] a) {
         throw new UnsupportedOperationException();
      }

      private class za implements Iterator<K> {
         private int b;

         private za() {
            this.b = -1;
         }

         public boolean hasNext() {
            return this.b + 1 < zd.this.b();
         }

         public K next() {
            if (++this.b >= zd.this.b()) {
               throw new NoSuchElementException("Iteration has no more elements.");
            } else {
               return za.this.b.c(this.b);
            }
         }

         public void remove() {
            throw new UnsupportedOperationException();
         }

         // $FF: synthetic method
         za(Object var2) {
            this();
         }
      }
   }

   private class zb implements Iterator<za<K, V>> {
      private int b;

      private zb() {
         this.b = -1;
      }

      public boolean hasNext() {
         return this.b + 1 < zd.this.b();
      }

      public za<K, V> a() {
         if (++this.b >= zd.this.b()) {
            throw new NoSuchElementException("Iteration has no more elements.");
         } else {
            return new za(zd.this.c(this.b), zd.this.b(this.b));
         }
      }

      public void remove() {
         throw new UnsupportedOperationException();
      }

      // $FF: synthetic method
      public Object next() {
         return this.a();
      }

      // $FF: synthetic method
      zb(Object var2) {
         this();
      }
   }
}
